import { BasicColumn, FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { listCashierTags, listPayPassage } from './payPassage.api';
import { } from '/@/enum/pageEnums'

export enum ConfigPageType {
  JSON = '1',
  CUSTOM = '2'
}

export const columns: BasicColumn[] = [
  {
    title: '支付方式代码',
    width: 100,
    dataIndex: 'wayCode'
  },
  {
    title: '支付方式名称',
    width: 100,
    dataIndex: 'wayName',
  },
  {
    dataIndex: 'status', 
    title: '状态',
    width: 40,
    customRender: ({text}) => {
      let color = "green"
      if (text == '0') color = '#FFCC33'
      if (text == '1') color = 'green'
      
      return render.renderTag(render.renderDict(text, 'data_use_status'), color)
    },
  }
];

export const cashierConfigColumns: BasicColumn[] = [
  {
    dataIndex: 'sourceName', 
    title: '来源',
    helpMessage: [
      '收银台会通过来源获取可用的支付列表',
      '收银台来源字典code: pay_order_source'
    ],
    width: 220,
    customRender: ({text}) => {
      let color = "green"
      return render.renderTag(text, color)
    },
  },
  {
    title: '默认',
    dataIndex: 'isDefault',
    width: 60,
    customRender: ({text}) => {
      const color = text === '1' ? 'orange' : 'cyan'
      return render.renderTag(render.renderDict(text, 'bool_value'), color)
    }
  },
  {
    title: '支付接口',
    width: 120,
    dataIndex: 'ifName'
  },
  {
    title: '支付方式代码',
    width: 150,
    dataIndex: 'wayCode'
  },
  {
    title: '支付方式名称',
    width: 150,
    dataIndex: 'wayName',
  }
];

export const cashierConfigFormSchema: FormSchema[] = [
  {
    field: 'id',
    label: '',
    component: 'Input',
    show: false
  },
  {
    field: 'appId',
    label: '',
    component: 'Input',
    show: false
  },
  {
    field: 'passageId',
    label: '支付通道',
    required: true,
    component: 'ApiSelect',
    dynamicDisabled: ({ values }) => { return !!values.id},
  },
  {
    field: 'isDefault',
    label: '默认',
    required: true,
    component: 'JDictSelectTag',
    defaultValue:'0',
    componentProps: {
      type:'radio',
      dictCode:'bool_value',
    },
  },
  {
    field: 'source',
    label: '来源',
    component: 'JDictSelectTag',
    componentProps: {
      showSearch: true,
      dictCode: 'pay_order_source',
    }
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    componentProps: {
      autoSize: {
        minRows: 3,
        maxRows: 8
      }
    }
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'wayCode',
    label: '支付方式代码',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    field: 'wayName',
    label: '支付方式名称',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode:'data_use_status',
      placeholder:'请选择状态'
    }
  },
];


export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: '通道id',
    show: false,
    component: 'Input'
  },
  
  {
    field: 'status',
    label: '状态',
    component: 'JDictSelectTag',
    defaultValue: "0",
    componentProps: {
      dictCode:'data_use_status',
      type:'radio'
    }
  },
  {
    field: 'riskConfig',
    label: '风控数据',
    component: 'InputTextArea',
  },
  {
    field: 'rate',
    label: '支付方式费率',
    required: true,
    defaultValue: 0,
    helpMessage: '单位是%',
    component: 'Input',
  },
  {
    field: 'remark',
    label: '备注',
    componentProps: {
      
    },
    component: 'InputTextArea',
    colProps: {
      style: 'color: red',
      sm: 24, // ≥576px
    }
  },
  
]

